package com.nbstar.film.spider.font.woff;

import org.apache.commons.lang3.builder.ReflectionToStringBuilder;

import java.io.IOException;

/**
 * The table directory is an array of WOFF table directory entries, as defined
 * below. The directory follows immediately after the WOFF file header;
 * therefore, there is no explicit offset in the header pointing to this block.
 * Its size is calculated by multiplying the numTables value in the WOFF header
 * times the size of a single WOFF table directory. Each table directory entry
 * specifies the size and location of a single font data table.
 *
 * @version 1.0.0
 * @link
 * @since 2018/6/15
 */

public class TableDirectory {

    private String tag;
    private int offset;
    private int compLength;
    private int origLength;
    private int origChecksum;
    private byte[] data;

    private AbstractOTFDataStream stream;

    public TableDirectory() {
    }

    public TableDirectory(AbstractOTFDataStream stream) throws IOException {
        this.stream = stream;
    }

    public TableDirectory(String tag, int offset, int compLength, int origLength, int origChecksum) {
        this.tag = tag;
        this.offset = offset;
        this.compLength = compLength;
        this.origLength = origLength;
        this.origChecksum = origChecksum;
    }

    public String getTag() {
        return tag;
    }

    public void setTag(String tag) {
        this.tag = tag;
    }

    public int getOffset() {
        return offset;
    }

    public void setOffset(int offset) {
        this.offset = offset;
    }

    public int getCompLength() {
        return compLength;
    }

    public void setCompLength(int compLength) {
        this.compLength = compLength;
    }

    public int getOrigLength() {
        return origLength;
    }

    public void setOrigLength(int origLength) {
        this.origLength = origLength;
    }

    public int getOrigChecksum() {
        return origChecksum;
    }

    public void setOrigChecksum(int origChecksum) {
        this.origChecksum = origChecksum;
    }

    public byte[] getData() {
        return data;
    }

    public void setData(byte[] data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return ReflectionToStringBuilder.toString(this);
    }
}
